import { Navigate } from "react-router";

const getToken = () => {
    return localStorage.token
}

function WithAuth(props:{ children:JSX.Element }) {
    const token = getToken()
    if(token){
        return <>{props.children}</>
    }else{
        return <Navigate to='/login'></Navigate>
    }
}

export default WithAuth;